<%@ page language="java" contentType="text/html;charset=UTF-8"%>
<%@ include file="/commons/taglibs.jsp"%>
<%@ include file="/commons/commonEdit.jsp"%>
<%@ include file="/commons/validation.jsp"%>
<%@ taglib uri="/WEB-INF/tld/pms-tag.tld" prefix="mypms" %>
<html>
<head>
<title>${key.coalitionEditTitle}</title>
<script language="JavaScript"  src="${ctx}/scripts/div/common.js"></script>
<script language="JavaScript" type="text/javascript" src="${ctx}/scripts/public3.js"></script>
<script language="javascript">
function init(){
	var colitionTypeCode = "${coalitionHouse.coalitionType}";
	var choiceHouse = "${coalitionHouse.choiceHouseStr}";
	if(${coalitionHouse.coalitionStrategy} == 0){
		$('strategy2').checked = true;
		document.getElementById('tab06').style.display = "";
		document.getElementById('tab05').style.display = "none";
	}else{
		$('strategy1').checked = true;
	}
	bank = new Bank('bankId','accNumber','accOwner','contactNumber');
	bank.init(bank);
	$('bankId').fireEvent("onchange");
}

function clearValue(){
	if($('strategy1').checked == true){
		document.getElementById('bankId').value="";
		var inputs = $('tab06').getElementsByTagName('INPUT');
		for(var i = 0 ; i < inputs.length; i++){
			inputs[i].value = "";
		}
    }
}
function mySubmit()
{
	var isTrue=$('coalitionHouseForm').fireEvent("onSubmit");
	if(isTrue){
	    clearValue();
		var param = Form.serialize('coalitionHouseForm');
		var url = "${ctx}/house_coalitionHouseAction.do?method=editCoalitionHouse";
	    new Ajax.Request(url,{method: 'post',
					parameters :param ,
					onSuccess : function(response) {
	                 if('true' == response.responseText){
				     	 var obj = findFrame('connTabPanel');
					     obj.parent.refleshFrame();
					     windowClose();
				   	 }
				   	 else{
				   	 	ajaxSubmitException(response.responseText);
				   	 }
					}});
	}
}
function Bank(bankName,bankNumber,accountOwner,contactNumber){
		var _bank = null;//自身的引用,这样可以引用其他方法
		var _bankNameObj = $(bankName);//银行名称下拉框
		var _bankNumberObj = $(bankNumber);//银行帐号
		var _accountObj = $(accountOwner);//银行帐号
		var _contactObj = $(contactNumber);//合同号

		var _require = "aux_intable_require";//必选样式
		var _notRequire  = "aux_intable_td2";//不必选样式

		this.init = function(abank){
			_bank = abank;
		}

		//设置各输入东东状态, true代表可用,false代表不可用
		this.setStatuz = function(flag){
			_bankNameObj.disabled = !flag;
			_bankNumberObj.disabled = !flag;
			_accountObj.disabled = !flag;
			_contactObj.disabled = !flag;
		}
		//银行名称下拉框onchange处理事件
		this.bankNameEventHandle = function(selectedIndex){
			var flag = selectedIndex != 0;
			if(flag){
				_bankNameObj.parentNode.className = _require;

				_bankNumberObj.parentNode.className = _require;
				Validation.changeElmValidate(_bankNumberObj.id,"required");

				_accountObj.parentNode.className = _require;
				Validation.changeElmValidate(_accountObj.id, "required");

				_bank.setStatuz(flag);//设置所有的东东可以用
			}else{
				_bankNameObj.parentNode.className = _notRequire;
				Validation.changeElmValidate(_bankNameObj.id,"");
				_bankNumberObj.parentNode.className = _notRequire;

				Validation.changeElmValidate(_bankNumberObj.id,"");

				_accountObj.parentNode.className = _notRequire;
				Validation.changeElmValidate(_accountObj.id,"");


				_bank.setStatuz(flag);//先设置所有的不可用,然后把银行名称下拉框设置回来
				_bankNameObj.disabled = false;
			}
		}
	}
</script>
</head>
<body onload="init();">
<table width="100%" border="0" cellpadding="0" cellspacing="0">
  <tr>
    <td class="window_head_outBg"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td><img src="${ctx}/images/ico_Advance.gif" width="16" height="16" align="absmiddle"> <span class="window_head_intext">${key.coalitionEditTitle}</span></td>
        </tr>
    </table></td>
  </tr>
  <tr>
    <td class="aux_header_line_1"></td>
  </tr>
  <tr>
    <td class="aux_header_line_2"></td>
  </tr>
  <tr>
    <td valign="middle" class="content">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" class="container_in_show">
      <tr>
        <td valign="top">
	        <div id="tab_Search" >
	              <table width="100%" border="0" cellpadding="0" cellspacing="0" id="tab_subMenu1">
	                <tr>
	                  <td><table width="100%" border="0" align="center" cellpadding="5" cellspacing="0">

	                      <tr>
	                        <td>
	                            <form action="" method="post" id="coalitionHouseForm" class="required-validate">
	                            <input type="hidden" name="coalitionId" value="${coalitionHouse.coalitionId}">
	                            <input type="hidden" name ="keyword" value = "${bankAccount.keyword}">
	                            <input type="hidden" type="hidden" name="choiceHouseStr" value="${coalitionHouse.choiceHouseStr}">
	           					<table width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color">
	          					  <tr>
	            					<td  class="aux_intable_td1">${key.coalitionRelationType}：</td>
	            					<td  class="aux_intable_require">
	            						<mypms:Sysrefcode id="coationType" name="coalitionType"selectValue="${coalitionHouse.coalitionType}" showTip="true" code="HM_REAL_R_VIRTUAL_RELATION_TYPE" style="width:110px" className="select-one-required"  >
	            						</mypms:Sysrefcode>
	            					</td>
	            				  </tr>
	            				  <tr>
		                                <td  class="aux_intable_td1">${key.coalitionHouseNumber}：</td>
		                                <td  class="aux_intable_require"><input name="coalitionHouseNumber" type="text" class="required" value="${coalitionHouse.coalitionHouseNumber}" size="16" maxlength="36"></td>
	                              </tr>
	            				 <tr>
            				  	       <td  class="aux_intable_td1">${key.house_coalitionHouse_strategy}：</td>
            				           <td valign="top" class="aux_intable_require">
            				     	     <input type="radio" id="strategy1" name="coalitionStrategy" value="1" onClick="showOrhidden('tab05','show'),display('tab06','hidden')" class="validate-one-required">${key.house_coalitionHouse_separate}
            				     	     <input type="radio" id="strategy2" name="coalitionStrategy" value="0" onClick="display('tab06','show'),display('tab05','hidden')" class="validate-one-required">${key.house_coalitionHouse_merge}
            				           </td>
          					      </tr>
	         					  <tr>
	            					 <td valign="top"  class="aux_intable_td1">${key.chooseHouse}：</td>
	            					 <td valign="top"  class="aux_intable_td2">
	            						${coalitionHouseDisplay}
									 </td>
	          					  </tr>

								  <tbody colspan="2" width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color" id="tab05" style="display:show">
	         					  <tr>
	            					 <td valign="top"  class="aux_intable_td1">&nbsp;</td>
	            					 <td valign="top"  class="aux_intable_td2">&nbsp;</td>
	          					  </tr>
	          					  </tbody>

	          					  <tbody  colspan="2" width="100%" border="0" cellpadding="0" cellspacing="1" class="aux_intable_color" id="tab06" style="display:none">
	          					  <tr>
							                <td  class="aux_intable_td1">${key.house_coalitionHouse_bank}：</td>
							                <td  class="aux_intable_td2">
							                	<pms:unitedSelect name="bankId"
					            					  id="bankId"
					              					  dataList="${bankList}"
					              					  optionLabel="bankName"
					              					  optionValue="keyword"
					              					  onChange="bank.bankNameEventHandle(this.selectedIndex);"
					              					  value="${bankAccount.bankId}"
					              					  selectText="请选择..."
					              					  className="select-one-required">
					               				</pms:unitedSelect>
							                </td>
						                </tr>
						                <tr>
							                <td  class="aux_intable_td1">${key.house_coalitionHouse_accNumber}：</td>
							                <td  class="aux_intable_td2"><input id="accNumber" name="accNumber" type="text"  value="${bankAccount.accNumber}" size="16" maxlength="20"></td>
						                </tr>
						                <tr>
							                <td  class="aux_intable_td1">${key.house_coalitionHouse_accOwner}：</td>
							                <td  class="aux_intable_td2">
							                  <input id="accOwner" name="accOwner" type="text" class="inputtext" value="${bankAccount.accOwner}" size="16" maxlength="32"></td>
						                </tr>
						                <tr>
							                <td  class="aux_intable_td1">${key.house_coalitionHouse_contactNumber}：</td>
							                <td  class="aux_intable_td2">
							                  <input name="contactNumber" type="text" class="inputtext" value="${bankAccount.contactNumber}" size="16" maxlength="100"></td>
						               </tr>
	          					  </tbody>
	       					 </table>
							</form>
	         				</td>
	       				 </tr>
	       			</table>
	       		 </td>
	       		</tr>
	          </table>
			</div>
		</td>
      </tr>
    </table>
	</td>
  </tr>
  <tr>
    <td class="window_footer"><table border="0" cellpadding="0" cellspacing="0">
      <tr>
        <td>
        <table border="0" cellpadding="0" cellspacing="0" onclick="mySubmit();">
            <tr>
       		  <td class="btn_between_four"></td>
              <td class="buttonOffLeft" id="btn1_21"></td>
              <td class="buttonOffMiddle" id="btn1_22" onblur="btn_change(2)" onMouseOver="btn_change_over(2)" onMouseOut="btn_change_out(2)" onClick="closewin();"><img src="${ctx}/images/ico_ok.gif" border="0" align="absmiddle" /> ${key.save}</td>
              <td class="buttonOffRight" id="btn1_23"></td>
            </tr>
          </table>
          </td>
        <td class="btn_between_space"></td>
        <td>
        <table border="0" cellpadding="0" cellspacing="0" onClick="windowClose();">
            <tr>
              <td class="buttonOffLeft" id="btn1_31"></td>
              <td class="buttonOffMiddle" id="btn1_32" onblur="btn_change(3)" onMouseOver="btn_change_over(3)" onMouseOut="btn_change_out(3)"><img src="${ctx}/images/ico_cancel.gif" border="0" align="absmiddle" /> ${key.close}</td>
              <td class="buttonOffRight" id="btn1_33"></td>
            </tr>
        </table>
        </td>
      </tr>
    </table></td>
  </tr>
</table>
</body>
</html>